﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace QLNH_DAL_WS
{
    /// <summary>
    /// Summary description for QLNH_DAL_WebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class QLNH_DAL_WebService : System.Web.Services.WebService
    {
        #region AccountDAO

        [WebMethod]
        public bool IsValidAccount(string username)
        {
            AccountDAO account = new AccountDAO();
            return account.IsValidAccount(username);
        }

        [WebMethod]
        public AccountDetailDTO GetAccoutInfo(string username)
        {
            AccountDAO account = new AccountDAO();
            return account.GetAccoutInfo(username);
        }

        [WebMethod]
        public List<RoleDTO> GetAllRole()
        {
            AccountDAO account = new AccountDAO();
            return account.GetAllRole();
        }

        [WebMethod]
        public List<AccountDetailDTO> GetAllAccountDetail(string username, string roleID)
        {
            AccountDAO accountDAO = new AccountDAO();
            return accountDAO.GetAllAccountDetail(username, roleID);
        }

        [WebMethod]
        public bool AddAccount(AccountDTO accountDTO)
        {
            AccountDAO accountDAO = new AccountDAO();
            return accountDAO.AddAccount(accountDTO);
        }

        [WebMethod]
        public bool EditAccount(AccountDTO accountDTO)
        {
            AccountDAO accountDAO = new AccountDAO();
            return accountDAO.EditAccount(accountDTO);
        }

        [WebMethod]
        public bool RemoveAccount(string id)
        {
            AccountDAO account = new AccountDAO();
            return account.RemoveAccount(id);
        }

        #endregion

        #region InfoDAO

        [WebMethod]
        public InfoDTO GetInfo()
        {
            InfoDAO info = new InfoDAO();
            return info.GetInfo();
        }

        [WebMethod]
        public bool UpdateInfo(InfoDTO infoDTO)
        {
            InfoDAO info = new InfoDAO();
            return info.UpdateInfo(infoDTO);
        }

        #endregion

        #region CatalogDAO

        [WebMethod]
        public List<CatalogDTO> GetAllCatalog()
        {
            CatalogDAO catalogDAO = new CatalogDAO();
            return catalogDAO.GetAllCatalog();
        }

        [WebMethod]
        public List<CatalogDetailDTO> GetAllCatalogDetail()
        {
            CatalogDAO catalogDAO = new CatalogDAO();
            return catalogDAO.GetAllCatalogDetail();
        }

        [WebMethod]
        public bool AddCatalog(CatalogDTO catalogDTO)
        {
            CatalogDAO catalogDAO = new CatalogDAO();
            return catalogDAO.AddCatalog(catalogDTO);
        }

        [WebMethod]
        public bool EditCatalog(CatalogDetailDTO catalogDetail)
        {
            CatalogDAO catalogDAO = new CatalogDAO();
            return catalogDAO.EditCatalog(catalogDetail);
        }

        [WebMethod]
        public bool RemoveCatalog(string catalogID)
        {
            CatalogDAO catalogDAO = new CatalogDAO();
            return catalogDAO.RemoveCatalog(catalogID);
        }

        #endregion

        #region MealDAO

        [WebMethod]
        public List<MealDetailDTO> GetAllMealDetail(string name, string catalogName)
        {
            MealDAO mealDAO = new MealDAO();
            return mealDAO.GetAllMealDetail(name, catalogName);
        }

        [WebMethod]
        public List<FoodReportDTO> GetCalledMeals(string catalogID)
        {
            return new MealDAO().GetCalledMeals(catalogID);
        }

        [WebMethod]
        public List<FoodReportDTO> GetCalledMealsByDate(DateTime start, DateTime end, string catalogID)
        {
            return new MealDAO().GetCalledMealsByDate(start, end, catalogID);
        }

        [WebMethod]
        public bool AddMeal(MealDTO mealDTO)
        {
            MealDAO mealDAO = new MealDAO();
            return mealDAO.AddMeal(mealDTO);
        }

        [WebMethod]
        public bool EditMeal(MealDTO mealDTO)
        {
            MealDAO mealDAO = new MealDAO();
            return mealDAO.EditMeal(mealDTO);
        }

        [WebMethod]
        public bool RemoveMeal(string id)
        {
            MealDAO mealDAO = new MealDAO();
            return mealDAO.RemoveMeal(id);
        }

        [WebMethod]
        public List<string> GetAllUnit()
        {
            MealDAO mealDAO = new MealDAO();
            return mealDAO.GetAllUnit();
        }

        [WebMethod]
        public double GetPrice(string mealID)
        {
            return new MealDAO().GetPrice(mealID);
        }
        #endregion

        #region TableDAO

        [WebMethod]
        public List<TableDTO> GetAllTable()
        {
            TableDAO tableDAO = new TableDAO();
            return tableDAO.GetAllTable();
        }

        [WebMethod]
        public bool AddTable(int capacity)
        {
            TableDAO tableDAO = new TableDAO();
            return tableDAO.AddTable(capacity);
        }

        [WebMethod]
        public bool EditTable(TableDTO tableDTO)
        {
            TableDAO tableDAO = new TableDAO();
            return tableDAO.EditTable(tableDTO);
        }

        [WebMethod]
        public bool RemoveTable(string id)
        {
            TableDAO tableDAO = new TableDAO();
            return tableDAO.RemoveTable(id);
        }

        [WebMethod]
        public List<TableDTO> GetAllEmptyTable()
        {
            return new TableDAO().GetAllEmptyTable();
        }
        #endregion

        #region EventDAO

        [WebMethod]
        public List<EventDTO> GetAllEvent()
        {
            EventDAO eventDAO = new EventDAO();
            return eventDAO.GetAllEvent();
        }

        [WebMethod]
        public bool AddEvent(EventDTO eventDTO)
        {
            EventDAO eventDAO = new EventDAO();
            return eventDAO.AddEvent(eventDTO);
        }

        [WebMethod]
        public bool EditEvent(EventDTO eventDTO)
        {
            EventDAO eventDAO = new EventDAO();
            return eventDAO.EditEvent(eventDTO);
        }

        [WebMethod]
        public bool RemoveEvent(string id)
        {
            EventDAO eventDAO = new EventDAO();
            return eventDAO.RemoveEvent(id);
        }

        #endregion

        #region OrderDAO

        [WebMethod]
        public int GenerateOrderNo()
        {
            return new OrderDetailDAO().GenerateOrderNo();
        }

        [WebMethod]
        public List<OrderDetailDTO> GetAllOrderDetail()
        {
            return new OrderDetailDAO().GetAllOrderDetail();
        }
        [WebMethod]
        public OrderDetailDTO GetOrder(int orderNo)
        {
            return new OrderDetailDAO().GetOrder(orderNo);
        }
        [WebMethod]
        public void AddOrder(OrderDetailDTO order)
        {
            new OrderDetailDAO().AddOrder(order);
        }
        [WebMethod]
        public void DeleteOrder(int orderNo)
        {
            new OrderDetailDAO().DeleteOrder(orderNo);
        }
        [WebMethod]
        public void UpdateOrder(OrderDetailDTO order)
        {
            new OrderDetailDAO().UpdateOrder(order);
        }
        [WebMethod]
        public void UpdateOrderState(int orderNo, State state)
        {
            new OrderDetailDAO().UpdateOrderState(orderNo, state);
        }
        #endregion

        #region BillDAO

        [WebMethod]
        public List<BillDTO> GetAllBill()
        {
            return new BillDAO().GetAllBill();
        }

        [WebMethod]
        public List<BillDTO> GetAllBillByDate(DateTime start, DateTime end)
        {
            return new BillDAO().GetAllBill(start, end);
        }

        [WebMethod]
        public bool InsertBill(List<BillDetailDTO> billDetail)
        {
            return new BillDAO().InsertBill(billDetail);
        }

        #endregion
    }
}
